﻿using System.Collections.Generic;
using Orchard.Mvc.Routes;
using System.Web.Routing;
using System.Web.Mvc;
using Orchard.Environment.Extensions;

namespace FruitCake.ContactPage
{
    [OrchardFeature("FruitCake.ContactPage")]
    public class Routes : IRouteProvider 
    {
        public void GetRoutes(ICollection<RouteDescriptor> routes)
        {
            foreach (var descriptor in GetRoutes())
                routes.Add(descriptor);
        }

        public IEnumerable<RouteDescriptor> GetRoutes()
        {
            return new[] 
            {
                new RouteDescriptor {   
                    Priority = 5,
                    Route = new Route("Admin/ContactPage/Requests",
                        new RouteValueDictionary {
                            {"area", "FruitCake.ContactPage"},
                            {"controller", "Admin"},
                            {"action", "Index"}
                        },
                        new RouteValueDictionary(),
                        new RouteValueDictionary {
                            {"area", "FruitCake.ContactPage"}
                        },
                        new MvcRouteHandler())
                },

                new RouteDescriptor {   
                    Priority = 5,
                    Route = new Route("Admin/ContactPage/Request/{id}",
                        new RouteValueDictionary {
                            {"area", "FruitCake.ContactPage"},
                            {"controller", "Admin"},
                            {"action", "Details"}, 
                        },
                        new RouteValueDictionary {
                            {"id", @"\d+"}
                        },
                        new RouteValueDictionary {
                            {"area", "FruitCake.ContactPage"}
                        },
                        new MvcRouteHandler())
                },

                new RouteDescriptor {   
                    Priority = 5,
                    Route = new Route("Admin/ContactPage/Request/Edit/{id}",
                        new RouteValueDictionary {
                            {"area", "FruitCake.ContactPage"},
                            {"controller", "Admin"},
                            {"action", "Edit"}
                        },
                        new RouteValueDictionary {
                            {"id", @"\d+"}
                        },
                        new RouteValueDictionary {
                            {"area", "FruitCake.ContactPage"}
                        },
                        new MvcRouteHandler())
                }
            };
        }

    }
}